import {Component} from "react";
import {getDate} from "../../../utils/DateUtils";

class PubMessage extends Component{
    state={
        time: getDate()
    }
    componentDidMount() {
        this.timer = setInterval(() => {
            this.setState({
                time: getDate()
            })
        }, 1000)
    }

    componentWillUnmount() {
        setTimeout(this.timer)
    }

    render() {
        let {time} = this.state
        return(
            <div>
                pub-message
                <div>
                    {time}
                </div>
            </div>
        )
    }
}

export default PubMessage;